
package cn.edu.scau.cmi.hombio.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.math.BigDecimal;

import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.codehaus.jackson.annotate.JsonIgnore;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllPreventionTypes", query = "select myPreventionType from PreventionType myPreventionType"),
		@NamedQuery(name = "findPreventionTypeById", query = "select myPreventionType from PreventionType myPreventionType where myPreventionType.id = ?1"),
		@NamedQuery(name = "findPreventionTypeByMemo", query = "select myPreventionType from PreventionType myPreventionType where myPreventionType.memo = ?1"),
		@NamedQuery(name = "findPreventionTypeByMemoContaining", query = "select myPreventionType from PreventionType myPreventionType where myPreventionType.memo like ?1"),
		@NamedQuery(name = "findPreventionTypeByName", query = "select myPreventionType from PreventionType myPreventionType where myPreventionType.name = ?1"),
		@NamedQuery(name = "findPreventionTypeByNameContaining", query = "select myPreventionType from PreventionType myPreventionType where myPreventionType.name like ?1"),
		@NamedQuery(name = "findPreventionTypeByPrimaryKey", query = "select myPreventionType from PreventionType myPreventionType where myPreventionType.id = ?1"),
		@NamedQuery(name = "findPreventionTypeByQuality", query = "select myPreventionType from PreventionType myPreventionType where myPreventionType.quality = ?1"),
		@NamedQuery(name = "findPreventionTypeByReportQuality", query = "select myPreventionType from PreventionType myPreventionType where myPreventionType.reportQuality = ?1") })

@Table(catalog = "pig", name = "prevention_type")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain", name = "PreventionType")
@XmlRootElement(namespace = "pigRs/cn/edu/scau/cmi/hombio/domain")
public class PreventionType implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "Id", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@Id @GeneratedValue
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "Name", nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String name;
	/**
	 */

	@Column(name = "ReportQuality")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	Integer reportQuality;
	/**
	* ͷ��
	* 
	 */

	@Column(name = "Quality", scale = 2, precision = 11, nullable = false)
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	BigDecimal quality;
	/**
	 */

	@Column(name = "Memo")
	@Basic(fetch = FetchType.EAGER)

	@XmlElement
	String memo;

	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "ReportMedicineId", referencedColumnName = "Id") })
	@XmlTransient
	Medicine medicineByReportMedicineId;
	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "MedicineId", referencedColumnName = "Id", nullable = false) })
	@XmlTransient
	Medicine medicineByMedicineId;
	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "UnitId", referencedColumnName = "Id", nullable = false) })
	@XmlTransient
	Unit unitByUnitId;
	/**
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns({ @JoinColumn(name = "ReportUnitId", referencedColumnName = "Id") })
	@XmlTransient
	Unit unitByReportUnitId;
	/**
	 */
	@OneToMany(mappedBy = "preventionType", cascade = { CascadeType.REMOVE }, fetch = FetchType.LAZY)

	
	java.util.Set<cn.edu.scau.cmi.hombio.domain.TaskPrevention> taskPreventions;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 */
	public String getName() {
		return this.name;
	}

	/**
	 */
	public void setReportQuality(Integer reportQuality) {
		this.reportQuality = reportQuality;
	}

	/**
	 */
	public Integer getReportQuality() {
		return this.reportQuality;
	}

	/**
	* ͷ��
	* 
	 */
	public void setQuality(BigDecimal quality) {
		this.quality = quality;
	}

	/**
	* ͷ��
	* 
	 */
	public BigDecimal getQuality() {
		return this.quality;
	}

	/**
	 */
	public void setMemo(String memo) {
		this.memo = memo;
	}

	/**
	 */
	public String getMemo() {
		return this.memo;
	}

	/**
	 */
	public void setMedicineByReportMedicineId(Medicine medicineByReportMedicineId) {
		this.medicineByReportMedicineId = medicineByReportMedicineId;
	}

	/**
	 */
	@JsonIgnore
	public Medicine getMedicineByReportMedicineId() {
		return medicineByReportMedicineId;
	}

	/**
	 */
	public void setMedicineByMedicineId(Medicine medicineByMedicineId) {
		this.medicineByMedicineId = medicineByMedicineId;
	}

	/**
	 */
	@JsonIgnore
	public Medicine getMedicineByMedicineId() {
		return medicineByMedicineId;
	}

	/**
	 */
	public void setUnitByUnitId(Unit unitByUnitId) {
		this.unitByUnitId = unitByUnitId;
	}

	/**
	 */
	@JsonIgnore
	public Unit getUnitByUnitId() {
		return unitByUnitId;
	}

	/**
	 */
	public void setUnitByReportUnitId(Unit unitByReportUnitId) {
		this.unitByReportUnitId = unitByReportUnitId;
	}

	/**
	 */
	@JsonIgnore
	public Unit getUnitByReportUnitId() {
		return unitByReportUnitId;
	}

	/**
	 */
	public void setTaskPreventions(Set<TaskPrevention> taskPreventions) {
		this.taskPreventions = taskPreventions;
	}

	/**
	 */
	@JsonIgnore
	public Set<TaskPrevention> getTaskPreventions() {
		if (taskPreventions == null) {
			taskPreventions = new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPrevention>();
		}
		return taskPreventions;
	}

	/**
	 */
	public PreventionType() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(PreventionType that) {
		setId(that.getId());
		setName(that.getName());
		setReportQuality(that.getReportQuality());
		setQuality(that.getQuality());
		setMemo(that.getMemo());
		setMedicineByReportMedicineId(that.getMedicineByReportMedicineId());
		setMedicineByMedicineId(that.getMedicineByMedicineId());
		setUnitByUnitId(that.getUnitByUnitId());
		setUnitByReportUnitId(that.getUnitByReportUnitId());
		setTaskPreventions(new java.util.LinkedHashSet<cn.edu.scau.cmi.hombio.domain.TaskPrevention>(that.getTaskPreventions()));
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("name=[").append(name).append("] ");
		buffer.append("reportQuality=[").append(reportQuality).append("] ");
		buffer.append("quality=[").append(quality).append("] ");
		buffer.append("memo=[").append(memo).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof PreventionType))
			return false;
		PreventionType equalCheck = (PreventionType) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
